<template>
	
	<div >
		<div class="jian" v-on:click="jian()"> - </div>
		<div class="number">{{config.count}}</div>
		<div class="jia" v-on:click="jia()"> + </div>
		
	</div>


</template>

<script>

import { Toast } from 'mint-ui';
	
export default {

	name : 'count',

	data () {
		return {
			
		}

	},

	props: {
	    config: {
	      type: Object,
	      default: {
	      		//'count' : 1,
	      }
	    },
	    
	},


	computed : {

	},

	methods : {
		jian () {
			if(this.config.count > 1){
				this.config.count -= 1;
			}

			//this.$emit('change', { 'count' : this.config.count });
		},

		jia () {

			if(this.config.max === -1){
				this.config.count += 1;
			}else{
				if(this.config.count < this.config.max){
					this.config.count += 1;
				}else{
					Toast({
					  message: '最大数量不能超过 ' + this.config.max,
					  position: 'bottom',
					  duration : 5000,
					  className : 'zindex'
					});
				}
			}

			//this.$emit('change', { 'count' : this.config.count });
			
		},

	},

	create () {


	}

}


</script>

<style scoped>

.jian, .jia {
	width: 35px;
	height: 35px;
	text-align: center;
	line-height: 30px;
	float: left;
	border: 1px solid #aaa;

}

.number {
	width: 40px;
	height: 35px;
	float: left;
	border-top: 1px solid #aaa;
	border-bottom: 1px solid #aaa;
	text-align: center;
	line-height: 35px;
}



</style>